function convertToObject(input) {
    const result = {};

    for (const key in input) {
        const parts = key.split('.');

        let currentObj = result;

        for (let i = 0; i < parts.length; i++) {
            const part = parts[i];
            const isArrayElement = part.includes('[');

            if (isArrayElement) {
                const [arrayKey, indexStr] = part.split('[');
                const index = indexStr.replace(']', '') * 1; // 将字符串乘以1进行转换

                currentObj[arrayKey] = currentObj[arrayKey] || [];

                if (i === parts.length - 1) {
                    currentObj[arrayKey][index] = input[key];
                } else {
                    currentObj = currentObj[arrayKey][index] = currentObj[arrayKey][index] || {};
                }
            } else {
                if (i === parts.length - 1) {
                    currentObj[part] = input[key];
                } else {
                    currentObj = currentObj[part] = currentObj[part] || {};
                }
            }
        }
    }

    return result;
}

const input = {
    'a.b': 1,
    'a.c': 2,
    'a.d.e': 5,
    'b[0]': 1,
    'b[1]': 3,
    'b[2].a': 2,
    'b[2].b': 3,
    'c': 3
};

const result = convertToObject(input);
console.log(result)